paned: Implement increased handle area using pick()
authorTimm Bäder <mail@baedert.org>
Wed, 13 Feb 2019 14:37:54 +0000 (15:37 +0100)
committerTimm Bäder <mail@baedert.org>
Sat, 16 Feb 2019 10:19:29 +0000 (11:19 +0100)
Otherwise, we do report the widgets below the invisible handle area as
hovered or active.

gtk/gtkpaned.c

index c4bb503e39a0681cdcc2f7754ca9c93fa2b20669..2cd216657e3641a74b6558841b127af2faf124f5 100644 (file)
@@ -326,6 +326,23 @@ gtk_paned_motion (GtkEventControllerMotion *motion,
     }
 }
 
+static GtkWidget *
+gtk_paned_pick (GtkWidget *widget,
+                double     x,
+                double     y)
+{
+  GtkPaned *paned = GTK_PANED (widget);
+  GtkPanedPrivate *priv = gtk_paned_get_instance_private (paned);
+  graphene_rect_t handle_area;
+
+  get_handle_area (paned, &handle_area);
+
+  if (graphene_rect_contains_point (&handle_area, &(graphene_point_t){x, y}))
+    return priv->handle_widget;
+
+  return GTK_WIDGET_CLASS (gtk_paned_parent_class)->pick (widget, x, y);
+}
+
 static void
 gtk_paned_class_init (GtkPanedClass *class)
 {
@@ -348,6 +365,7 @@ gtk_paned_class_init (GtkPanedClass *class)
   widget_class->size_allocate = gtk_paned_size_allocate;
   widget_class->unrealize = gtk_paned_unrealize;
   widget_class->focus = gtk_paned_focus;
+  widget_class->pick = gtk_paned_pick;
 
   container_class->add = gtk_paned_add;
   container_class->remove = gtk_paned_remove;